package com.me.modules.report.controller;

import com.me.modules.common.controller.BaseController;
import com.me.modules.common.page.Page;
import com.me.modules.common.utils.JsonUtil;
import com.me.modules.common.utils.Utils;
import com.me.modules.report.service.RepositoryReportService;
import com.me.modules.sys.service.CodeService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;

import javax.servlet.http.HttpServletRequest;
import java.util.*;


/**
 * 事件报表
 *
 * @author lill
 * @email lill5270@163.com
 * @date 2019-01-16 17:20:30
 */
@Controller
@RequestMapping("/report/repositoryreport")
public class RepositoryReportController extends BaseController{
	@Autowired
	private RepositoryReportService repositoryReportService;
	@Autowired
	private CodeService codeService;


	/**
	 * 列表
	 */
	@RequestMapping("/RepositoryOrignPie")
//	@RequiresPermissions("srminfo:list")
//	@SysLog("查询变更列表")
	public String RepositoryOrignPie(@RequestParam Map<String, Object> params, Model model , HttpServletRequest request){
		List<Object> list =repositoryReportService.RepositoryOrignPie(params);
		model.addAttribute("params",params);
		model.addAttribute("data",JsonUtil.getJsonByObj(list));
		return "report/repository/RepositoryOrignPie";
	}


	/**
	 * 列表
	 */
	@RequestMapping("/RepositoryLineMonthNumber")
	public String RepositoryLineMonthNumber(@RequestParam Map<String, Object> params, Model model , HttpServletRequest request){
		Date endDate= (Date) params.get("endDate");
		if(endDate==null){
			params.put("endDate",new  Date());
		}
		List<Object> list =repositoryReportService.RepositoryLineMonthNumber(params);
		model.addAttribute("params",params);
		model.addAttribute("data",JsonUtil.getJsonByObj(list));
		return "report/repository/RepositoryLineMonthNumber";
	}


	/**
	 * 列表
	 */
	@RequestMapping("/RepositoryGridUsability")
	public String RepositoryGridUsability(@RequestParam Map<String, Object> params, Model model , HttpServletRequest request){
		int pageNum = Utils.parseInt(request.getParameter("pageNum"), 1);
		Page<Object> page = repositoryReportService.RepositoryGridUsability(params, pageNum);

		model.addAttribute("params",params);
		model.addAttribute("page",page);
		return "report/repository/RepositoryGridUsability";
	}

}
